<?php
	header("Content-Type: application/vnd.ms-excel");
	header("Content-Disposition: attachment; filename=\"liste_commandes.xls\"");
?>
<table>
	<caption>Liste des commandes ouvertes</caption>
	<tr>
		<th>Identifiant commande</th>
		<th>Nom utilisateur</th>
		<th>Prenom utilisateur</th>
		<th>Mail utilisateur</th>
		<th>Produits</th>
	</tr>
	<?php
		foreach($commandes as $c){
			if($c['Commande']['etat_id'] == 1){
				echo "<tr>";
				echo "<td>" . $c['Commande']['id'] . "</td>";
				echo "<td>" . $c['User']['nom'] . "</td>";
				echo "<td>" . $c['User']['prenom'] . "</td>";
				echo "<td>" . $c['User']['mail'] . "</td>";
				foreach($c['Row'] as $r){
					echo "<td>" . $r['quantite'] . "*" . $r['Product']['nom'] . "</td>";
				}
				echo "</tr>";
			}
		}
	?>
</table>

<table></table>
<table></table>
<table></table>

<table>
	<caption>Liste des commandes en cours</caption>
	<tr>
		<th>Identifiant commande</th>
		<th>Nom utilisateur</th>
		<th>Prenom utilisateur</th>
		<th>Mail utilisateur</th>
		<th>Produits</th>
	</tr>
	<?php
		foreach($commandes as $c){
			if($c['Commande']['etat_id'] == 2){
				echo "<tr>";
				echo "<td>" . $c['Commande']['id'] . "</td>";
				echo "<td>" . $c['User']['nom'] . "</td>";
				echo "<td>" . $c['User']['prenom'] . "</td>";
				echo "<td>" . $c['User']['mail'] . "</td>";
				foreach($c['Row'] as $r){
					echo "<td>" . $r['quantite'] . "*" . $r['Product']['nom'] . "</td>";
				}
				echo "</tr>";
			}
		}
	?>
</table>

<table></table>
<table></table>
<table></table>

<table>
	<caption>Liste des commandes terminees</caption>
	<tr>
		<th>Identifiant commande</th>
		<th>Nom utilisateur</th>
		<th>Prenom utilisateur</th>
		<th>Mail utilisateur</th>
		<th>Produits</th>
	</tr>
	<?php
		foreach($commandes as $c){
			if($c['Commande']['etat_id'] == 3){
				echo "<tr>";
				echo "<td>" . $c['Commande']['id'] . "</td>";
				echo "<td>" . $c['User']['nom'] . "</td>";
				echo "<td>" . $c['User']['prenom'] . "</td>";
				echo "<td>" . $c['User']['mail'] . "</td>";
				foreach($c['Row'] as $r){
					echo "<td>" . $r['quantite'] . "*" . $r['Product']['nom'] . "</td>";
				}
				echo "</tr>";
			}
		}
	?>
</table>